<template>
    <!-- 导航栏 -->
    <view class="navBar">
        <view class="navigationBar">
            <view class="navigation iconfont">
                <view class="navigation_before" @tap="navigationBack"> &#xe712;</view>
                <view> &#xe6b1;</view>
                <view class="navigation_home" @tap="navigationHome"> &#xe618;</view>
            </view>
            <text class="navigation_title">{{ navigationTitle }}</text>
        </view>
    </view>
    <view class="h_hidden_box"></view>
</template>

<script setup>
import { ref } from 'vue';
import Taro from '@tarojs/taro';


const navigationTitle = ref('')
const navigationBack = ref(() => {
    const pages = getCurrentPages();
    if (pages.length > 1) {
        Taro.navigateBack({
            delta: 1
        });
    } else {
        navigationHome.value();
    }
});


// 需要使用ref实时更新该函数！！！
const navigationHome = ref(() => {

});
// 暴露参数和方法给父组件
defineExpose({
    navigationTitle,
    navigationBack,
    navigationHome
});
</script>

<style>
.navBar {
    position: fixed;
    width: 100%;
    height: 195rpx;
    background-color: #fff;
    z-index: 2;
}

.navigationBar {
    position: relative;
    margin-top: 100rpx;
    margin-bottom: 30rpx;
    width: 100%;
    height: 60rpx;
    line-height: 60rpx;
    font-weight: 700;
    text-align: center;
}

.navigation {
    position: absolute;
    font-weight: 1;
    display: flex;
    flex-direction: row;
    justify-content: center;
    color: #bfbfbf;
    left: 15rpx;
    width: 160rpx;
    height: 60rpx;
    font-size: 45rpx;
    border-radius: 40rpx;
    border: 1px solid #cfcfcf;

}

.navigation_title {
    display: inline-block;
    height: 60rpx;
    width: 350rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navigation_before {
    color: #000;

}

.navigation_home {
    color: #000;
}

.h_hidden_box {
    width: 100%;
    height: 195rpx;


}
</style>
